from typing import List


class Solution:
    def exchange(self, nums: List[int]) -> List[int]:
        x, y = 0, len(nums)-1
        while x < y:
            while x < y and nums[x]%2==1:
                x += 1
            while x < y and nums[y]%2==0:
                y -= 1
            nums[x], nums[y] = nums[y], nums[x]
        return nums

if __name__ == '__main__':
    s = Solution()
    print(s.exchange([1,3,5]))